package com.solution.delegate;

import java.util.List;
import java.util.Set;

import com.solution.exception.DelegateException;
import com.solution.exception.ServiceBeanException;
import com.solution.exception.ServiceLocatorException;
import com.solution.model.AnswerType;
import com.solution.model.CategoryType;
import com.solution.model.ExamCategoryLevelMapping;
import com.solution.model.ExamType;
import com.solution.model.LevelType;
import com.solution.model.QuestionType;
import com.solution.service.AnswerTypeService;
import com.solution.service.CategoryTypeService;
import com.solution.service.ExamTypeService;
import com.solution.service.LevelTypeService;
import com.solution.service.QuestionTypeService;
import com.solution.util.SearchVO;
import com.solution.util.ServiceLocator;

public class ExaminationServiceDelegate implements AnswerTypeService, ExamTypeService, CategoryTypeService, 
	LevelTypeService, QuestionTypeService{

	private AnswerTypeService answerTypeService;
	private CategoryTypeService categoryTypeService;
	private ExamTypeService examTypeService;
	private LevelTypeService levelTypeService;
	private QuestionTypeService questionTypeService;

	public ExaminationServiceDelegate() throws DelegateException{
		try {
			answerTypeService = (AnswerTypeService)ServiceLocator.getInstance().getRemoteService("AnswerTypeService");
			categoryTypeService = (CategoryTypeService)ServiceLocator.getInstance().getRemoteService("CategoryTypeService");
			examTypeService = (ExamTypeService)ServiceLocator.getInstance().getRemoteService("ExamTypeService");
			levelTypeService = (LevelTypeService)ServiceLocator.getInstance().getRemoteService("LevelTypeService");
			questionTypeService = (QuestionTypeService)ServiceLocator.getInstance().getRemoteService("QuestionTypeService");
		}
		catch (ServiceLocatorException e) {
			throw new DelegateException(e); 
		}
	}
	
	public List<AnswerType> fetchActiveAnswers(Long questionTypeId) throws ServiceBeanException{
		return answerTypeService.fetchActiveAnswers(questionTypeId);
	}
	public AnswerType fetchCorrectAnswer(Long questionTypeId) throws ServiceBeanException{
		return answerTypeService.fetchCorrectAnswer(questionTypeId);
	}
	public AnswerType createAnswer(AnswerType answer) throws ServiceBeanException{
		return answerTypeService.createAnswer(answer);
	}
	public List<CategoryType> fetchActiveCategories() throws ServiceBeanException{
		return categoryTypeService.fetchActiveCategories();
	}
	public List<CategoryType> getCategories(SearchVO searchVO) throws ServiceBeanException{
		return categoryTypeService.getCategories(searchVO);
	}
	public CategoryType getCategory(Long categoryTypeId) throws ServiceBeanException{
		return categoryTypeService.getCategory(categoryTypeId);
	}
	public ExamType getExam(Long examTypeId) throws ServiceBeanException{
		return examTypeService.getExam(examTypeId);
	}
	public List<ExamType> fetchActiveExams() throws ServiceBeanException{
		return examTypeService.fetchActiveExams();
	}
	public List<ExamType> fetchExams(SearchVO searchVO) throws ServiceBeanException{
		return examTypeService.fetchExams(searchVO);
	}
	public ExamType createExam(ExamType examType, List<ExamCategoryLevelMapping> questionTypes) 
		throws ServiceBeanException{
		return examTypeService.createExam(examType, questionTypes);
	}
	public ExamType updateExam(ExamType examType, List<ExamCategoryLevelMapping> questionTypes) 
		throws ServiceBeanException{
		return examTypeService.updateExam(examType, questionTypes);
	}
	public List<LevelType> fetchActiveLevels() throws ServiceBeanException{
		return levelTypeService.fetchActiveLevels();
	}
	public List<LevelType> getLevels(SearchVO searchVO) throws ServiceBeanException{
		return levelTypeService.getLevels(searchVO);
	}
	public LevelType getLevel(Long levelTypeId) throws ServiceBeanException{
		return levelTypeService.getLevel(levelTypeId);
	}
	public QuestionType fetchQuestion(Long questionTypeId) throws ServiceBeanException{
		return questionTypeService.fetchQuestion(questionTypeId);
	}
	public Set<QuestionType> fetchActiveQuestions(Long categoryTypeId, Long levelTypeId, Long numberOfQs) 
		throws ServiceBeanException{
		return questionTypeService.fetchActiveQuestions(categoryTypeId, levelTypeId, numberOfQs);
	}
	public List<QuestionType> fetchQuestions(SearchVO searchVO) throws ServiceBeanException{
		return questionTypeService.fetchQuestions(searchVO);
	}
	public QuestionType createQuestionAnswer(QuestionType question, List<AnswerType> answers) 
		throws ServiceBeanException{
		return questionTypeService.createQuestionAnswer(question, answers);
	}
	public QuestionType updateQuestionAnswer(QuestionType question, List<AnswerType> answers) 
		throws ServiceBeanException{
		return questionTypeService.updateQuestionAnswer(question, answers);
	}

	public List<ExamCategoryLevelMapping> fetchExamCategoryLevelMapping(SearchVO searchVO) throws ServiceBeanException {		
		return examTypeService.fetchExamCategoryLevelMapping(searchVO);
	}

	public CategoryType createCategory(CategoryType category) throws ServiceBeanException {		
		return categoryTypeService.createCategory(category);
	}
}
